#pragma once

#include "HSModelAPI.h"

#include "Wm5Vector2.h"
#include "Wm5Line3.h"
#include "Wm5Line2.h"
#include "Wm5Box3.h"
#include "Wm5Box2.h"
#include "Wm5Triangle3.h"
#include "Wm5Triangle2.h"
#include "Wm5Ray3.h"
#include "Wm5Ray2.h"

typedef Wm5::Line3    <double> TLine3;
typedef Wm5::Box3     <double> TBox3;
typedef Wm5::Vector3  <double> TVector3;
typedef Wm5::Vector2  <double> TVector2;
typedef Wm5::Triangle3<double> TTriangle3;
typedef Wm5::Triangle2<double> TTriangle2;
typedef Wm5::Ray3     <double> TRay3;
typedef Wm5::Line2    <double> TLine2;
typedef Wm5::Box2     <double> TBox2;
typedef Wm5::Ray2     <double> TRay2;

// Intersection test for 3d-line and 3d-box
//  Return true if nonempty intersection
//  Return false otherwise
HSMODEL_API bool IntersectionTest(const TLine3&, const TBox3&);

// Intersection test for 3d-line and 3d-triangle
HSMODEL_API bool IntersectionTest(const TLine3&, const TTriangle3&);

// Intersection test for two 3-d boxes
HSMODEL_API bool IntersectionTest(const TBox3&, const TBox3&);

// Intersection test for two 3-d triangles
HSMODEL_API bool IntersectionTest(const TTriangle3&, const TTriangle3&);

// Defines if two triangles intersects on area, but NOT a point or segment!  
HSMODEL_API bool AreaIntersectionTest(const TTriangle2&, const TTriangle2&);

// Intersection test for 3-d triangle and 3-d box
HSMODEL_API bool IntersectionTest(const TTriangle3&, const TBox3&);

// Intersection test for 3-d triangle and 3-d ray
HSMODEL_API bool IntersectionTest(const TTriangle3&, const TRay3&);

// Intersection point of 3-d triangle and 3-d ray
HSMODEL_API bool GetIntersectionPoint(TVector3& o_result, const TTriangle3&, const TRay3&);

// Distance between two points
HSMODEL_API double GetDistanceBetweenPoints(const TVector3& i_a, const TVector3& i_b);

// Check if points of polygon are in clockwise order
HSMODEL_API bool IsInClockwiseOrder2D(const std::vector<TVector2>& i_points);

// First found intersection point of 2-d box and 2-d line
HSMODEL_API bool GetIntersectionPoint(TVector2& o_result, const TBox2&, const TRay2&);

// Getting projection of the 3-d line on the ground surface
HSMODEL_API TRay2 GetProjectionOnXY(const TLine3&);

// Getting projection of the 3-d triangle on the ground surface
HSMODEL_API TTriangle2 GetProjectionOnXY(const TTriangle3&);